package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.TrackInfo;
import com.atguigu.tingshu.query.album.TrackInfoQuery;
import com.atguigu.tingshu.vo.album.AlbumTrackListVo;
import com.atguigu.tingshu.vo.album.TrackListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TrackInfoMapper extends BaseMapper<TrackInfo> {


    Integer selectorderNumByAlbumId(Long albumId);


    Page<TrackListVo> findUserTrackPage(TrackInfoQuery trackInfoQuery, Page<TrackListVo> pageInfo,Long userId);

    void selectTrackByAlbumId(Long albumId);

    List<AlbumTrackListVo> getAlbumTrackListVo(Page<AlbumTrackListVo> trackInfoIPage, Long albumId);

    /**
     * 获取指定专辑的最大排序号
     * @param albumId
     * @return
     */
    @Select("select order_num from track_info where album_id = #{albumId} ORDER BY order_num desc limit 1")
    public Integer selectTrackMaxOrderNum(@Param("albumId") Long albumId);
}
